#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

const int N = 100;

string n;
int k;

bool isPalindromic(string s)
{
    int l = 0, r = s.size() - 1;
    while (l <= r)
    {
        if (s[l] != s[r])
            return false;
        l++;
        r--;
    }
    return true;
}

// 大数加法
string add_large_num(string a, string b)
{
    int e = 0, len = a.size();
    string res = "";
    for (int i = len - 1; i >= 0; i--)
    {
        int t = (a[i] - '0') + (b[i] - '0') + e;
        if (t >= 10)
        {
            res += t % 10 + '0';
            e = t / 10;
        }
        else
        {
            res += t + '0';
            e = 0;
        }
    }
    if (e != 0)
        res += e + '0';
    reverse(res.begin(), res.end());
    return res;
}

inline void solution()
{
    cin >> n >> k;
    int i;
    if (isPalindromic(n))
    {
        cout << n << endl
             << 0 << endl;
        return;
    }
    for (i = 1; i <= k; i++)
    {
        string a = n;
        reverse(n.begin(), n.end());
        string b = n;
        string c = add_large_num(a, b);
        if (isPalindromic(c))
        {
            cout << c << endl
                 << i << endl;
            return;
        }
        n = c;
    }
    cout << n << endl
         << k << endl;
}

string multiply(string num1, string num2)
{
    int len1 = num1.size() - 1, len2 = num2.size() - 1;
    string res(len1 + len2 + 2, '0');

    for (int i = len1; i >= 0; i--)
    {
        for (int j = len2; j >= 0; j--)
        {
            int temp = (res[i + j + 1] - '0') + (num1[i] - '0') * (num2[j] - '0');
            res[i + j + 1] = temp % 10 + '0';
            res[i + j] += temp / 10;
        }
    }
    for (int i = 0; i < len1 + len2 + 2; i++)
    {
        if (res[i] != '0')
            return res.substr(i);
    }
    return "0";
}

int main()
{
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}

// 注意需要用到超大数相加。